package com.huluobo.a2308douyindemo.net

import com.huluobo.a2308douyindemo.bean.AccountBean
import com.huluobo.a2308douyindemo.bean.CollectBean
import com.huluobo.a2308douyindemo.bean.CommentBean
import com.huluobo.a2308douyindemo.bean.DanmakuBean
import com.huluobo.a2308douyindemo.bean.Gift7037Bean
import com.huluobo.a2308douyindemo.bean.HomeBannerBean
import com.huluobo.a2308douyindemo.bean.HomeBillBean
import com.huluobo.a2308douyindemo.bean.HomeGoodsBean
import com.huluobo.a2308douyindemo.bean.HomeGoodsInfo
import com.huluobo.a2308douyindemo.bean.HomeNavBean
import com.huluobo.a2308douyindemo.bean.LikeBean
import com.huluobo.a2308douyindemo.bean.ReplyBean
import com.huluobo.a2308douyindemo.bean.UserBean
import com.huluobo.a2308douyindemo.bean.VideoBean
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.HTTP
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Query

/**
 *  Created by LC on 2025/10/16.
 *  存放所有网络请求
 */
interface ApiService {

    @POST(Const.URL_LOGIN)
    suspend fun login(
        @Query(Const.PARAM_USERNAME) username: String,
        @Query(Const.PARAM_PASSWORD) password: String
    ): Res<UserBean>

    @POST(Const.URL_REGISTER)
    suspend fun register(
        @Query(Const.PARAM_USERNAME) username: String,
        @Query(Const.PARAM_PASSWORD) password: String
    ): Res<UserBean>

    @GET(Const.URL_GET_VIDEOS)
    suspend fun getVideos(
        @Query(Const.PARAM_PAGE) page: Int,
        @Query(Const.PARAM_PAGE_SIZE) pageSIze: Int
    ): Res<List<VideoBean>>

    @PUT(Const.URL_LIKE_VIDEO)
    suspend fun likeVideo(@Body body: RequestBody): Res<LikeBean>

    @GET(Const.URL_GET_LIKE_VIDEOS)
    suspend fun getLikeVideos(
        @Query(Const.PARAM_SOURCE_FLAG) sourceFlag: String,
        @Query(Const.PARAM_LIKE_USER_ID) userId: Int
    ): Res<List<VideoBean>>

    //强制一个没有body的请求方法,可以拥有body
    @HTTP(method = "DELETE", path = Const.URL_GET_UN_LIKE_VIDEO, hasBody = true)
//    @DELETE(Const.URL_GET_UN_LIKE_VIDEO)
    suspend fun unLikeVideo(@Body body: RequestBody): Res<String>

    @GET(Const.URL_GET_COMMENT)
    suspend fun getComments(
        @Query(Const.PARAM_DATE_TYPE) dateType: Int,
        @Query(Const.PARAM_ITEM_ID) itemId: String
    ): Res<List<CommentBean>>

    @POST(Const.URL_SEND_COMMENT)
    suspend fun sendComment(@Body body: RequestBody): Res<CommentBean>

    @POST(Const.URL_REPLY_COMMENT)
    suspend fun replyComment(@Body body: RequestBody): Res<ReplyBean>

    @POST(Const.URL_COMMENT_LIKE)
    suspend fun commentLike(@Query(Const.PARMA_COMMENT_ID) commentId: Int): Res<Boolean>

    @POST(Const.URL_FOCUS)
    suspend fun focusUser(
        @Query(Const.PARAM_FOCUSE_USER_ID) userId: Int,
        @Query(Const.PARAM_FOCUSED_USER_ID) authId: String
    ): Res<Boolean>

    @DELETE(Const.URL_UN_FOCUS)
    suspend fun unFocsUser(
        @Query(Const.PARAM_FOCUSE_USER_ID) userId: Int,
        @Query(Const.PARAM_FOCUSED_USER_ID) authId: String
    ): Res<Boolean>

    @POST(Const.URL_COLLECT_VIDEO)
    suspend fun collectVideo(@Body body: RequestBody): Res<CollectBean>

    @POST(Const.URL_SEND_DANMAKU)
    suspend fun sendDanmaku(@Body body: RequestBody): Res<DanmakuBean>

    @GET(Const.URL_GET_DANMAKU)
    suspend fun getDanmaku(
        @Query(Const.PARAM_DATA_TYPE) dataType: Int,
        @Query(Const.PARAM_ITEM_ID) itemId: String
    ): Res<List<DanmakuBean>>

    @GET(Const.URL_GET_GIFT_7037)
    suspend fun getGift(): Res<List<Gift7037Bean>>

    @POST(Const.URL_ADD_ACCOUNT)
    suspend fun addAccount(@Body body: RequestBody): Res<AccountBean>

    @GET(Const.URL_GET_ACCOUNT_BY_USER_ID)
    suspend fun getAccountByUserId(@Query(Const.PARAM_USER_ID) userId: Int): Res<AccountBean>

    @PUT(Const.URL_MODIFY_COIN)
    suspend fun modifyCoin(@Query(Const.PARAM_ID) id: Int, @Query(Const.PARAM_UM) um: String): Res<Boolean>

    @PUT(Const.URL_MODIFY_ACCOUNT)
    suspend fun modifyAccount(@Query(Const.PARAM_ID) id: Int, @Query(Const.PARAM_UM) um: String): Res<Boolean>

    @GET(Const.URL_HOME_BANNER)
    suspend fun getHomeBanner(): Res<List<HomeBannerBean>>

    @GET(Const.URL_HOME_NAV)
    suspend fun getHomeNav(): Res<List<HomeNavBean>>

    @GET(Const.URL_HOME_GOODS_INFO)
    suspend fun getHomeGoodsInfo(): Res<List<HomeGoodsBean>>

    @GET(Const.URL_HOME_BILL)
    suspend fun getHomeBill(): Res<List<HomeBillBean>>

    @GET(Const.URL_GET_COLLECT)
    suspend fun getCollect(
        @Query(Const.PARAM_LIKE_USER_ID) userId: Int,
        @Query(Const.PARAM_SOURCE_FLAG) sourceFlag: String
    ): Res<List<VideoBean>>

}